﻿using MediatR;
using SystemWFH.API.Application.Command.WorkshopCommand;
using SystemWFH.Infrstructer.Interface;

namespace SystemWFH.API.Application.CommandHandlers.WorkshopCommandHandler
{
    /// <summary>
    /// 单删除
    /// </summary>
    public class WorkshopDeletesCommandHandler : IRequestHandler<WorkshopDeletesCommand, int>
    {
        private readonly IWorkshopRepository workshopRepository;
        public WorkshopDeletesCommandHandler(IWorkshopRepository workshopRepository)
        {
            this.workshopRepository = workshopRepository;
        }

        public async Task<int> Handle(WorkshopDeletesCommand request, CancellationToken cancellationToken)
        {
            var list = await workshopRepository.GetValue(request.workshopId);
            list.IsDelete = true;
            list.DelectTime = DateTime.Now.ToUniversalTime();
            list.DelectName = "李明";
            return await workshopRepository.UpdateAsync(list);
        }
    }
}
